﻿// MIT License
// 开源地址：https://gitee.com/co1024/AbcMvc
// Copyright (c) 2021-2023 1024
// Abc.Mvc=Furion+EF+SqlSugar+Pear layui admin.

namespace Abc.Core;

public class AppInfoOptions : IConfigurableOptionsListener<AppInfoOptions>
{
    public string Name { get; set; }
    public string Version { get; set; }
    public string Company { get; set; }

    /// <summary>
    /// 文件保存路径
    /// </summary>
    public string WebUploadFloder { get; set; }

    /// <summary>
    /// URL访问的逻辑路径 域名/逻辑路径/文件相对路径
    /// 默认:/u/f
    /// </summary>
    public string WebUploadLogicalPath { get; set; }

    /// <summary>
    /// Cookie AES密钥
    /// </summary>
    public string CookieAesKey { get; set; }

    #region 后台登陆RSA密钥

    /// <summary>
    /// 后台登陆RSA 公钥
    /// </summary>
    public string HtAdminLoginRsaPublic { get; set; }

    /// <summary>
    /// 后台登陆RSA 私钥
    /// </summary>
    public string HtAdminLoginRsaPrivate { get; set; }

    #endregion 后台登陆RSA密钥

    public void OnListener(AppInfoOptions options, IConfiguration configuration)
    {
        Type entityType = GetType();//获得该类的Type

        var dics = options.GetDictionary();
        foreach (var item in dics)
        {
            PropertyInfo propertyInfo = entityType.GetProperty(item.Key);
            propertyInfo.FieldSetValue(item.Key, item.Value as object);
        }
    }

    public void PostConfigure(AppInfoOptions options, IConfiguration configuration)
    {
    }
}